/**
 *
 */
import OpenApi;
import OpenApi.OpenApiUtil;

extends OpenApi;


init(config: OpenApiUtil.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('tablestore', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!$isNull(endpoint)) {
    return endpoint;
  }
  
  if (!$isNull(endpointMap) && !$isNull(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return OpenApiUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model ChangeResourceGroupRequest {
  newResourceGroupId?: string(name='NewResourceGroupId', description='The ID of the new resource group.

This parameter is required.', example='rg-aek3bgek3kxhyky'),
  resourceId?: string(name='ResourceId', description='The resource ID, which is the instance name.

This parameter is required.', example='first-ins'),
}

model ChangeResourceGroupResponseBody = {
  requestId?: string(name='RequestId', description='The request ID, which can be used to troubleshoot issues.', example='39871ED2-62C0-578F-A32E-B88072D5582F'),
}

model ChangeResourceGroupResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ChangeResourceGroupResponseBody(name='body'),
}

/**
 * @summary Changes the resource group to which an instance belongs.
 *
 * @param request ChangeResourceGroupRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ChangeResourceGroupResponse
 */
async function changeResourceGroupWithOptions(request: ChangeResourceGroupRequest, headers: map[string]string, runtime: $RuntimeOptions): ChangeResourceGroupResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.newResourceGroupId)) {
    body['NewResourceGroupId'] = request.newResourceGroupId;
  }
  if (!$isNull(request.resourceId)) {
    body['ResourceId'] = request.resourceId;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'ChangeResourceGroup',
    version = '2020-12-09',
    protocol = 'HTTPS',
    pathname = `/v2/openapi/changeresourcegroup`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Changes the resource group to which an instance belongs.
 *
 * @param request ChangeResourceGroupRequest
 * @return ChangeResourceGroupResponse
 */
async function changeResourceGroup(request: ChangeResourceGroupRequest): ChangeResourceGroupResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return changeResourceGroupWithOptions(request, headers, runtime);
}

model CheckInstancePolicyRequest {
  instanceName?: string(name='InstanceName', description='The name of the instance.

This parameter is required.', example='workshop-bj-ots1'),
  policy?: string(name='Policy', description='The instance policy in the JSON format.

This parameter is required.', example='{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ots:*"
            ],
            "Resource": [
                "acs:ots:*:13791xxxxxxxxxxx:instance/myinstance*"
            ],
            "Principal": [
                "*"
            ],
            "Effect": "Allow",
            "Condition": {
                "StringEquals": {
                    "ots:TLSVersion": [
                        "1.2"
                    ]
                },
                "IpAddress": {
                    "acs:SourceIp": [
                        "192.168.0.1",
                        "172.16.0.1"
                    ]
                }
            }
        }
    ]
}'),
}

model CheckInstancePolicyResponseBody = {
  code?: string(name='Code', description='The HTTP status code.', example='OK'),
  message?: string(name='Message', description='The response message.', example='Verification passed.'),
  requestId?: string(name='RequestId', description='The request ID, which can be used to troubleshoot issues.', example='757E172A-F94B-5E78-8A23-D9068E42F2E9'),
}

model CheckInstancePolicyResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CheckInstancePolicyResponseBody(name='body'),
}

/**
 * @summary Checks the validity of a Resource Access Management (RAM) policy for an instance.
 *
 * @param request CheckInstancePolicyRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return CheckInstancePolicyResponse
 */
async function checkInstancePolicyWithOptions(request: CheckInstancePolicyRequest, headers: map[string]string, runtime: $RuntimeOptions): CheckInstancePolicyResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }
  if (!$isNull(request.policy)) {
    body['Policy'] = request.policy;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'CheckInstancePolicy',
    version = '2020-12-09',
    protocol = 'HTTPS',
    pathname = `/v2/openapi/checkinstancepolicy`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Checks the validity of a Resource Access Management (RAM) policy for an instance.
 *
 * @param request CheckInstancePolicyRequest
 * @return CheckInstancePolicyResponse
 */
async function checkInstancePolicy(request: CheckInstancePolicyRequest): CheckInstancePolicyResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return checkInstancePolicyWithOptions(request, headers, runtime);
}

model CreateInstanceRequest {
  clusterType?: string(name='ClusterType', description='The type of the instance.

This parameter is required.', example='SSD'),
  disableReplication?: boolean(name='DisableReplication', description='(Deprecated) Specifies whether to enable disaster recovery for the instance.

Valid values:

*   false
*   true', example='false'),
  instanceDescription?: string(name='InstanceDescription', description='The description of the instance. The instance description must be 3 to 256 characters in length.', example='the test instance'),
  instanceName?: string(name='InstanceName', description='The name of the instance. Instance naming conventions:

*   The name can contain only letters, digits, and hyphens (-).
*   The name must start with a letter.
*   The name cannot end with a hyphen (-).
*   The name is case-insensitive.
*   The name must be 3 to 16 characters in length.
*   The name cannot contain the following words: ali, ay, ots, taobao, and admin.

This parameter is required.', example='instance-test'),
  network?: string(name='Network', description='(Deprecated) The network type of the instance. Valid values: NORMAL and VPC_CONSOLE. Default value: NORMAL.', example='NORMAL'),
  networkSourceACL?: [ string ](name='NetworkSourceACL', description='The types of the source from which access is allowed. By default, the following source type is allowed:

TRUST_PROXY: console'),
  networkTypeACL?: [ string ](name='NetworkTypeACL', description='The types of the network from which access is allowed. By default, the following network types are allowed:

*   INTERNET: Internet
*   VPC: virtual private cloud (VPC)
*   CLASSIC: classic network'),
  policy?: string(name='Policy', description='The instance policy in the JSON format.', example='{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ots:*"
            ],
            "Resource": [
                "acs:ots:*:13791xxxxxxxxxxx:instance/myinstance*"
            ],
            "Principal": [
                "*"
            ],
            "Effect": "Allow",
            "Condition": {
                "StringEquals": {
                    "ots:TLSVersion": [
                        "1.2"
                    ]
                },
                "IpAddress": {
                    "acs:SourceIp": [
                        "192.168.0.1",
                        "198.51.100.1"
                    ]
                }
            }
        }
    ]
}'),
  resourceGroupId?: string(name='ResourceGroupId', description='The ID of the resource group to which the instance belongs.', example='rg-acfmxh4em5jnbcd'),
  tags?: [ 
    {
      key?: string(name='Key', description='The tag key. The tag key can be up to 64 characters in length.

This parameter is required.', example='p_instance'),
      value?: string(name='Value', description='The tag value. The tag value can be up to 64 characters in length.

This parameter is required.', example='0woauavextilfqr61'),
    }
  ](name='Tags', description='The tags.'),
}

model CreateInstanceResponseBody = {
  code?: string(name='Code', description='The HTTP status code.', example='200'),
  message?: string(name='Message', description='The response message.', example='success'),
  requestId?: string(name='RequestId', description='The request ID, which can be used to troubleshoot issues.', example='39871ED2-62C0-578F-A32E-B88072D5582F'),
}

model CreateInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateInstanceResponseBody(name='body'),
}

/**
 * @summary Creates an instance.
 *
 * @description *   **Before you call this operation, you must understand the billing and pricing of Tablestore. For more information, see [Billing overview](https://help.aliyun.com/document_detail/27291.html).**
 * *   Each Alibaba Cloud account can create up to 10 instances. The name of an instance must be unique within the region in which the instance resides.
 * *   After you create an instance, you cannot change the type of the instance. Proceed with caution.
 *
 * @param request CreateInstanceRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateInstanceResponse
 */
async function createInstanceWithOptions(request: CreateInstanceRequest, headers: map[string]string, runtime: $RuntimeOptions): CreateInstanceResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.clusterType)) {
    body['ClusterType'] = request.clusterType;
  }
  if (!$isNull(request.disableReplication)) {
    body['DisableReplication'] = request.disableReplication;
  }
  if (!$isNull(request.instanceDescription)) {
    body['InstanceDescription'] = request.instanceDescription;
  }
  if (!$isNull(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }
  if (!$isNull(request.network)) {
    body['Network'] = request.network;
  }
  if (!$isNull(request.networkSourceACL)) {
    body['NetworkSourceACL'] = request.networkSourceACL;
  }
  if (!$isNull(request.networkTypeACL)) {
    body['NetworkTypeACL'] = request.networkTypeACL;
  }
  if (!$isNull(request.policy)) {
    body['Policy'] = request.policy;
  }
  if (!$isNull(request.resourceGroupId)) {
    body['ResourceGroupId'] = request.resourceGroupId;
  }
  if (!$isNull(request.tags)) {
    body['Tags'] = request.tags;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'CreateInstance',
    version = '2020-12-09',
    protocol = 'HTTPS',
    pathname = `/v2/openapi/createinstance`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Creates an instance.
 *
 * @description *   **Before you call this operation, you must understand the billing and pricing of Tablestore. For more information, see [Billing overview](https://help.aliyun.com/document_detail/27291.html).**
 * *   Each Alibaba Cloud account can create up to 10 instances. The name of an instance must be unique within the region in which the instance resides.
 * *   After you create an instance, you cannot change the type of the instance. Proceed with caution.
 *
 * @param request CreateInstanceRequest
 * @return CreateInstanceResponse
 */
async function createInstance(request: CreateInstanceRequest): CreateInstanceResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return createInstanceWithOptions(request, headers, runtime);
}

model DeleteInstanceRequest {
  instanceName?: string(name='InstanceName', description='The name of the instance.

This parameter is required.', example='instance-test'),
}

model DeleteInstanceResponseBody = {
  requestId?: string(name='RequestId', description='The request ID, which can be used to troubleshoot issues.', example='17827FB1-CC71-559D-BBDF-9D41534322E7'),
}

model DeleteInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteInstanceResponseBody(name='body'),
}

/**
 * @summary Deletes an instance.
 *
 * @description *   Before you delete an instance, make sure that all data tables and time series tables in the instance are deleted and virtual private clouds (VPCs) are unbound from the instance.
 * *   To prevent conflicts, do not create an instance that has the same name as the instance that is being deleted.
 * *   After an instance is deleted, the instance becomes unavailable and the tables, table data, and related indexes in the instance cannot be recovered. Proceed with caution.
 *
 * @param request DeleteInstanceRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteInstanceResponse
 */
async function deleteInstanceWithOptions(request: DeleteInstanceRequest, headers: map[string]string, runtime: $RuntimeOptions): DeleteInstanceResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'DeleteInstance',
    version = '2020-12-09',
    protocol = 'HTTPS',
    pathname = `/v2/openapi/deleteinstance`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Deletes an instance.
 *
 * @description *   Before you delete an instance, make sure that all data tables and time series tables in the instance are deleted and virtual private clouds (VPCs) are unbound from the instance.
 * *   To prevent conflicts, do not create an instance that has the same name as the instance that is being deleted.
 * *   After an instance is deleted, the instance becomes unavailable and the tables, table data, and related indexes in the instance cannot be recovered. Proceed with caution.
 *
 * @param request DeleteInstanceRequest
 * @return DeleteInstanceResponse
 */
async function deleteInstance(request: DeleteInstanceRequest): DeleteInstanceResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteInstanceWithOptions(request, headers, runtime);
}

model DeleteInstancePolicyRequest {
  instanceName?: string(name='InstanceName', description='The name of the instance.

This parameter is required.', example='my-test-12345'),
  policyVersion?: long(name='PolicyVersion', description='The version of the instance policy.

This parameter is required.', example='2'),
}

model DeleteInstancePolicyResponseBody = {
  code?: string(name='Code', description='The HTTP status code.', example='200'),
  message?: string(name='Message', description='The response message.', example='success'),
  requestId?: string(name='RequestId', description='The request ID, which can be used to troubleshoot issues.', example='3104C83E-6E82-57FB-BB88-8C64CCFDEF89'),
}

model DeleteInstancePolicyResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteInstancePolicyResponseBody(name='body'),
}

/**
 * @summary Deletes a Resource Access Management (RAM) policy of an instance.
 *
 * @description *   You cannot recover a deleted instance policy. Proceed with caution.
 * *   After you delete an instance policy, the access control that is specified by the instance policy becomes invalid. Make sure that your instance is in a secure environment.
 *
 * @param request DeleteInstancePolicyRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteInstancePolicyResponse
 */
async function deleteInstancePolicyWithOptions(request: DeleteInstancePolicyRequest, headers: map[string]string, runtime: $RuntimeOptions): DeleteInstancePolicyResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }
  if (!$isNull(request.policyVersion)) {
    body['PolicyVersion'] = request.policyVersion;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'DeleteInstancePolicy',
    version = '2020-12-09',
    protocol = 'HTTPS',
    pathname = `/v2/openapi/deleteinstancepolicy`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Deletes a Resource Access Management (RAM) policy of an instance.
 *
 * @description *   You cannot recover a deleted instance policy. Proceed with caution.
 * *   After you delete an instance policy, the access control that is specified by the instance policy becomes invalid. Make sure that your instance is in a secure environment.
 *
 * @param request DeleteInstancePolicyRequest
 * @return DeleteInstancePolicyResponse
 */
async function deleteInstancePolicy(request: DeleteInstancePolicyRequest): DeleteInstancePolicyResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteInstancePolicyWithOptions(request, headers, runtime);
}

model DescribeRegionsRequest {
  clientToken?: string(name='ClientToken', description='The client token that is used to ensure the idempotence of the request.

>  #### You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length.', example='ETnLKlblzczshOTUbOCzxxxxxxxxxx'),
}

model DescribeRegionsResponseBody = {
  regions?: [ 
    {
      i18nKey?: string(name='I18nKey', description='The key of the region.', example='yunjiankong.cloud.region.cn-hangzhou'),
      regionId?: string(name='RegionId', description='The ID of the region.', example='cn-hangzhou'),
    }
  ](name='Regions', description='The regions.'),
  requestId?: string(name='requestId', description='The request ID, which can be used to troubleshoot issues.', example='B37BBA04-D827-55C8-B901-5264B904E8C6'),
}

model DescribeRegionsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeRegionsResponseBody(name='body'),
}

/**
 * @summary Queries supported regions.
 *
 * @param request DescribeRegionsRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeRegionsResponse
 */
async function describeRegionsWithOptions(request: DescribeRegionsRequest, headers: map[string]string, runtime: $RuntimeOptions): DescribeRegionsResponse {
  request.validate();
  var query : map[string]any = {};
  if (!$isNull(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'DescribeRegions',
    version = '2020-12-09',
    protocol = 'HTTPS',
    pathname = `/region/DescribeRegions`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries supported regions.
 *
 * @param request DescribeRegionsRequest
 * @return DescribeRegionsResponse
 */
async function describeRegions(request: DescribeRegionsRequest): DescribeRegionsResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return describeRegionsWithOptions(request, headers, runtime);
}

model GetInstanceRequest {
  instanceName?: string(name='InstanceName', description='The name of the instance.

This parameter is required.', example='instance-test'),
}

model GetInstanceResponseBody = {
  aliasName?: string(name='AliasName', description='The instance alias.', example='instance-test'),
  createTime?: string(name='CreateTime', description='The time when the instance was created.', example='2019-12-23T07:24:33Z'),
  elasticVCUUpperLimit?: float(name='ElasticVCUUpperLimit', description='The upper limit for the VCUs of the instance.', example='6'),
  instanceDescription?: string(name='InstanceDescription', description='The description of the instance.', example='Description of the test instance.'),
  instanceName?: string(name='InstanceName', description='The name of the instance.', example='instance-test'),
  instanceSpecification?: string(name='InstanceSpecification', description='The type of the instance.

*   SSD: high-performance instance
*   HYBRID: capacity instance', example='SSD'),
  instanceStatus?: string(name='InstanceStatus', description='The status of the instance.

*   normal: The instance works as expected.
*   forbidden: The instance is disabled.
*   Deleting: The instance is being deleted.', example='normal'),
  isMultiAZ?: boolean(name='IsMultiAZ', description='Indicates whether zone-redundant storage (ZRS) is enabled for the instance.

*   true: ZRS is enabled for the instance.
*   false: Locally redundant storage (LRS) is enabled for the instance.', example='true'),
  network?: string(name='Network', description='The network type of the instance. Valid values:

*   VPC: The instance can be accessed only over the bound virtual private clouds (VPCs).
*   VPC_CONSOLE: The instance can be accessed from the Tablestore console or over the bound VPCs.
*   NORMAL: The instance can be accessed from networks of the custom types.', example='VPC'),
  networkSourceACL?: [ string ](name='NetworkSourceACL', description='The sources of the network from which access is allowed. Valid value:

TRUST_PROXY: console'),
  networkTypeACL?: [ string ](name='NetworkTypeACL', description='The types of the network from which access is allowed. Valid values:

*   CLASSIC: the classic network
*   INTERNET: the Internet
*   VPC: VPCs'),
  paymentType?: string(name='PaymentType', description='The billing method. Valid values:

*   Subscription: subscription
*   PayAsYouGo: pay-as-you-go', example='Subscription'),
  policy?: string(name='Policy', description='The instance policy.', example='{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ots:*"
            ],
            "Resource": [
                "acs:ots:*:13791xxxxxxxxxxx:instance/myinstance*"
            ],
            "Principal": [
                "*"
            ],
            "Effect": "Allow",
            "Condition": {
                "StringEquals": {
                    "ots:TLSVersion": [
                        "1.2"
                    ]
                },
                "IpAddress": {
                    "acs:SourceIp": [
                        "192.168.0.1",
                        "198.51.100.1"
                    ]
                }
            }
        }
    ]
}'),
  policyVersion?: long(name='PolicyVersion', description='The version of the instance policy.', example='1'),
  regionId?: string(name='RegionId', description='The region ID of the instance.', example='cn-chengdu'),
  requestId?: string(name='RequestId', description='The request ID, which can be used to troubleshoot issues.', example='757E172A-F94B-5E78-8A23-D9068E42F2E9'),
  resourceGroupId?: string(name='ResourceGroupId', description='The ID of the resource group to which the instance belongs.', example='rg-acfmxh4em5jncda'),
  SPInstanceId?: string(name='SPInstanceId', description='The ID of the instance.', example='ots_standard_public_cn-9lb34u7u5001'),
  storageType?: string(name='StorageType', description='The storage type.

*   SSD: high-performance
*   HYBRID: capacity', example='HYBRID'),
  tableQuota?: int32(name='TableQuota', description='The total number of tables in the instance.', example='100'),
  tags?: [ 
    {
      key?: string(name='Key', description='The tag key.', example='tag'),
      tagKey?: string(name='TagKey', description='(Deprecated) The tag key.', example='keyTestA'),
      tagValue?: string(name='TagValue', description='(Deprecated) The tag value.', example='00004a20240452b0'),
      value?: string(name='Value', description='The tag value.', example='333'),
    }
  ](name='Tags', description='The tags of the instance.'),
  userId?: string(name='UserId', description='The user ID.', example='16542312566'),
  VCUQuota?: int32(name='VCUQuota', description='The VCU quota.', example='20'),
}

model GetInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetInstanceResponseBody(name='body'),
}

/**
 * @summary Queries instance information.
 *
 * @param request GetInstanceRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetInstanceResponse
 */
async function getInstanceWithOptions(request: GetInstanceRequest, headers: map[string]string, runtime: $RuntimeOptions): GetInstanceResponse {
  request.validate();
  var query : map[string]any = {};
  if (!$isNull(request.instanceName)) {
    query['InstanceName'] = request.instanceName;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetInstance',
    version = '2020-12-09',
    protocol = 'HTTPS',
    pathname = `/v2/openapi/getinstance`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries instance information.
 *
 * @param request GetInstanceRequest
 * @return GetInstanceResponse
 */
async function getInstance(request: GetInstanceRequest): GetInstanceResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return getInstanceWithOptions(request, headers, runtime);
}

model ListInstancesRequest {
  instanceName?: string(name='InstanceName', description='The name of the instance. Fuzzy search is supported.', example='instance'),
  instanceNameList?: [ string ](name='InstanceNameList', description='The names of the instances. This parameter is used to specify multiple instances that you want to query at the same time.'),
  maxResults?: int32(name='MaxResults', description='The maximum number of instances that you want to return. Valid values: 0 to 200. If you do not configure this parameter or set this parameter to 0, the default value of 100 is used.', example='100'),
  nextToken?: string(name='NextToken', description='The token that determines the start position of the query. Set this parameter to the value of the NextToken parameter that is returned from the last call. Instances are returned in lexicographical order starting from the position that is specified by this parameter. The first time you call the operation, leave this parameter empty.', example='CAESCG15aC1xxxxx'),
  resourceGroupId?: string(name='ResourceGroupId', description='The resource group ID. You can query the ID on the Resource Group page in the Resource Management console.', example='rg-aek24upgom6p5ri'),
  status?: string(name='Status', description='The instance status.', example='normal'),
  tag?: [ 
    {
      key?: string(name='Key'),
      value?: string(name='Value'),
    }
  ](name='Tag'),
}

model ListInstancesShrinkRequest {
  instanceName?: string(name='InstanceName', description='The name of the instance. Fuzzy search is supported.', example='instance'),
  instanceNameListShrink?: string(name='InstanceNameList', description='The names of the instances. This parameter is used to specify multiple instances that you want to query at the same time.'),
  maxResults?: int32(name='MaxResults', description='The maximum number of instances that you want to return. Valid values: 0 to 200. If you do not configure this parameter or set this parameter to 0, the default value of 100 is used.', example='100'),
  nextToken?: string(name='NextToken', description='The token that determines the start position of the query. Set this parameter to the value of the NextToken parameter that is returned from the last call. Instances are returned in lexicographical order starting from the position that is specified by this parameter. The first time you call the operation, leave this parameter empty.', example='CAESCG15aC1xxxxx'),
  resourceGroupId?: string(name='ResourceGroupId', description='The resource group ID. You can query the ID on the Resource Group page in the Resource Management console.', example='rg-aek24upgom6p5ri'),
  status?: string(name='Status', description='The instance status.', example='normal'),
  tagShrink?: string(name='Tag'),
}

model ListInstancesResponseBody = {
  instances?: [ 
    {
      aliasName?: string(name='AliasName', description='The instance alias.', example='instance-test'),
      createTime?: string(name='CreateTime', description='The time when the instance was created.', example='2019-04-07T09:19:21Z'),
      instanceDescription?: string(name='InstanceDescription', description='The instance description.', example='Description of the test instance.'),
      instanceName?: string(name='InstanceName', description='The name of the instance, which is used to uniquely identify the instance.', example='instance-test'),
      instanceSpecification?: string(name='InstanceSpecification', description='The type of the instance.

*   SSD: high-performance instance
*   HYBRID: capacity instance', example='HYBRID'),
      instanceStatus?: string(name='InstanceStatus', description='The instance status.

*   normal: The instance works as expected.
*   forbidden: The instance is disabled.
*   deleting: The instance is being deleted.', example='normal'),
      isMultiAZ?: boolean(name='IsMultiAZ', description='Indicates whether zone-redundant storage (ZRS) is enabled for the instance.

*   true: ZRS is enabled for the instance.
*   false: Locally redundant storage (LRS) is enabled for the instance.', example='true'),
      paymentType?: string(name='PaymentType', description='The billing method.

*   Subscription: subscription
*   PayAsYouGo: pay as you go', example='Subscription'),
      regionId?: string(name='RegionId', description='The region ID.', example='cn-huhehaote'),
      resourceGroupId?: string(name='ResourceGroupId', description='The ID of the resource group.', example='rg-acfmxh4em5jnbcd'),
      SPInstanceId?: string(name='SPInstanceId', description='The instance ID.', example='ots_standard_public_cn-g4t3igqjj002'),
      storageType?: string(name='StorageType', description='The storage type.

*   SSD: high-performance
*   HYBRID: capacity', example='HYBRID'),
      userId?: string(name='UserId', description='The user ID.', example='13542356466'),
      VCUQuota?: int32(name='VCUQuota', description='The VCU quota.', example='3'),
    }
  ](name='Instances', description='The details about the instances.'),
  nextToken?: string(name='NextToken', description='The token that determines the start position of the next query. If this parameter is empty, all instances that you want to query are returned.', example='CAESCG15aC1xxxxx'),
  requestId?: string(name='RequestId', description='The request ID, which can be used to troubleshoot issues.', example='E734979F-5A44-5993-9CE5-C23103576923'),
  totalCount?: long(name='TotalCount', description='The total number of instances returned.', example='2'),
}

model ListInstancesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListInstancesResponseBody(name='body'),
}

/**
 * @summary Queries instances.
 *
 * @param tmpReq ListInstancesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListInstancesResponse
 */
async function listInstancesWithOptions(tmpReq: ListInstancesRequest, headers: map[string]string, runtime: $RuntimeOptions): ListInstancesResponse {
  tmpReq.validate();
  var request = new ListInstancesShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!$isNull(tmpReq.instanceNameList)) {
    request.instanceNameListShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.instanceNameList, 'InstanceNameList', 'simple');
  }
  if (!$isNull(tmpReq.tag)) {
    request.tagShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.tag, 'Tag', 'json');
  }
  var query : map[string]any = {};
  if (!$isNull(request.instanceName)) {
    query['InstanceName'] = request.instanceName;
  }
  if (!$isNull(request.instanceNameListShrink)) {
    query['InstanceNameList'] = request.instanceNameListShrink;
  }
  if (!$isNull(request.maxResults)) {
    query['MaxResults'] = request.maxResults;
  }
  if (!$isNull(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!$isNull(request.resourceGroupId)) {
    query['ResourceGroupId'] = request.resourceGroupId;
  }
  if (!$isNull(request.status)) {
    query['Status'] = request.status;
  }
  if (!$isNull(request.tagShrink)) {
    query['Tag'] = request.tagShrink;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'ListInstances',
    version = '2020-12-09',
    protocol = 'HTTPS',
    pathname = `/v2/openapi/listinstances`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries instances.
 *
 * @param request ListInstancesRequest
 * @return ListInstancesResponse
 */
async function listInstances(request: ListInstancesRequest): ListInstancesResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return listInstancesWithOptions(request, headers, runtime);
}

model ListTagResourcesRequest {
  maxResults?: int32(name='MaxResults', description='The maximum number of tagged resources that you want to return. Valid values: 0 to 200. If you do not specify this parameter or set the parameter to 0, the default value of 100 is used.', example='20'),
  nextToken?: string(name='NextToken', description='The pagination token that is used in the next request to retrieve a new page of results. You do not need to specify this parameter for the first request. You must specify the token that is obtained from the previous query as the value of NextToken. Tagged resources are returned in lexicographical order starting from the position that is specified by this parameter.', example='CAESCG15aC1xxxxx'),
  resourceIds?: [ string ](name='ResourceIds', description='The resource IDs, which are instance names.'),
  resourceType?: string(name='ResourceType', description='The type of the resource. valid value:

instance: instance', example='instance'),
  tags?: [ 
    {
      key?: string(name='Key', description='The tag key.', example='Owner'),
      value?: string(name='Value', description='The tag value.', example='Tester'),
    }
  ](name='Tags', description='The tags.'),
}

model ListTagResourcesShrinkRequest {
  maxResults?: int32(name='MaxResults', description='The maximum number of tagged resources that you want to return. Valid values: 0 to 200. If you do not specify this parameter or set the parameter to 0, the default value of 100 is used.', example='20'),
  nextToken?: string(name='NextToken', description='The pagination token that is used in the next request to retrieve a new page of results. You do not need to specify this parameter for the first request. You must specify the token that is obtained from the previous query as the value of NextToken. Tagged resources are returned in lexicographical order starting from the position that is specified by this parameter.', example='CAESCG15aC1xxxxx'),
  resourceIdsShrink?: string(name='ResourceIds', description='The resource IDs, which are instance names.'),
  resourceType?: string(name='ResourceType', description='The type of the resource. valid value:

instance: instance', example='instance'),
  tagsShrink?: string(name='Tags', description='The tags.'),
}

model ListTagResourcesResponseBody = {
  maxResults?: int32(name='MaxResults', description='The maximum number of tagged resources that are returned for the query.', example='20'),
  nextToken?: string(name='NextToken', description='A pagination token. It can be used in the next request to retrieve a new page of results. If NextToken is empty, no next page exists.', example='CAESCG15aC1xxxxx'),
  tagResources?: [ 
    {
      resourceId?: string(name='ResourceId', description='The resource ID, which is the instance name.', example='instance-test'),
      resourceType?: string(name='ResourceType', description='The type of the resource.', example='ALIYUN::OTS::INSTANCE'),
      tagKey?: string(name='TagKey', description='The tag key.', example='Owner'),
      tagValue?: string(name='TagValue', description='The tag value.', example='Tester'),
    }
  ](name='TagResources', description='The tags.'),
  requestId?: string(name='requestId', description='The request ID, which can be used to troubleshoot issues.', example='31D8120C-AC52-5CA9-BE4A-E4C6316E19AD'),
}

model ListTagResourcesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListTagResourcesResponseBody(name='body'),
}

/**
 * @summary Queries tagged resources.
 *
 * @param tmpReq ListTagResourcesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListTagResourcesResponse
 */
async function listTagResourcesWithOptions(tmpReq: ListTagResourcesRequest, headers: map[string]string, runtime: $RuntimeOptions): ListTagResourcesResponse {
  tmpReq.validate();
  var request = new ListTagResourcesShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!$isNull(tmpReq.resourceIds)) {
    request.resourceIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.resourceIds, 'ResourceIds', 'simple');
  }
  if (!$isNull(tmpReq.tags)) {
    request.tagsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.tags, 'Tags', 'json');
  }
  var query : map[string]any = {};
  if (!$isNull(request.maxResults)) {
    query['MaxResults'] = request.maxResults;
  }
  if (!$isNull(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!$isNull(request.resourceIdsShrink)) {
    query['ResourceIds'] = request.resourceIdsShrink;
  }
  if (!$isNull(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  if (!$isNull(request.tagsShrink)) {
    query['Tags'] = request.tagsShrink;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'ListTagResources',
    version = '2020-12-09',
    protocol = 'HTTPS',
    pathname = `/v2/openapi/listtagresources`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries tagged resources.
 *
 * @param request ListTagResourcesRequest
 * @return ListTagResourcesResponse
 */
async function listTagResources(request: ListTagResourcesRequest): ListTagResourcesResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return listTagResourcesWithOptions(request, headers, runtime);
}

model TagResourcesRequest {
  resourceIds?: [ string ](name='ResourceIds', description='The resource IDs, which are instance names.

This parameter is required.'),
  resourceType?: string(name='ResourceType', description='The type of the resource. valid value:

instance: instance

This parameter is required.', example='instance'),
  tags?: [ 
    {
      key?: string(name='Key', description='The tag key.

This parameter is required.', example='created'),
      value?: string(name='Value', description='The tag value.

This parameter is required.', example='job-0007z8j1omiabo5i872l'),
    }
  ](name='Tags', description='The tags.

This parameter is required.'),
}

model TagResourcesResponseBody = {
  requestId?: string(name='RequestId', description='The request ID, which can be used to troubleshoot issues.', example='44FDC379-4443-560E-B652-9F7476D8854F'),
}

model TagResourcesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: TagResourcesResponseBody(name='body'),
}

/**
 * @summary Adds tags to instances.
 *
 * @param request TagResourcesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return TagResourcesResponse
 */
async function tagResourcesWithOptions(request: TagResourcesRequest, headers: map[string]string, runtime: $RuntimeOptions): TagResourcesResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.resourceIds)) {
    body['ResourceIds'] = request.resourceIds;
  }
  if (!$isNull(request.resourceType)) {
    body['ResourceType'] = request.resourceType;
  }
  if (!$isNull(request.tags)) {
    body['Tags'] = request.tags;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'TagResources',
    version = '2020-12-09',
    protocol = 'HTTPS',
    pathname = `/v2/openapi/tagresources`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Adds tags to instances.
 *
 * @param request TagResourcesRequest
 * @return TagResourcesResponse
 */
async function tagResources(request: TagResourcesRequest): TagResourcesResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return tagResourcesWithOptions(request, headers, runtime);
}

model UntagResourcesRequest {
  all?: boolean(name='All', description='Specifies whether to remove all tags from the resources. Default value: false.', example='false'),
  resourceIds?: [ string ](name='ResourceIds', description='The resource IDs, which are instance names.'),
  resourceType?: string(name='ResourceType', description='The type of the resource. valid value:

instance: instance', example='instance'),
  tagKeys?: [ string ](name='TagKeys', description='The tag keys.'),
}

model UntagResourcesResponseBody = {
  requestId?: string(name='requestId', description='The request ID, which can be used to troubleshoot issues.', example='26B43C99-F5C9-5341-B462-37427C5BF201'),
}

model UntagResourcesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UntagResourcesResponseBody(name='body'),
}

/**
 * @summary Removes tags from resources.
 *
 * @description Removing tags from resources helps simplify resource management, optimize system performance, and mitigate potential security vulnerabilities. After a tag is removed from a resource, the system automatically deletes the tag if the tag is not added to other resources.
 *
 * @param request UntagResourcesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return UntagResourcesResponse
 */
async function untagResourcesWithOptions(request: UntagResourcesRequest, headers: map[string]string, runtime: $RuntimeOptions): UntagResourcesResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.all)) {
    body['All'] = request.all;
  }
  if (!$isNull(request.resourceIds)) {
    body['ResourceIds'] = request.resourceIds;
  }
  if (!$isNull(request.resourceType)) {
    body['ResourceType'] = request.resourceType;
  }
  if (!$isNull(request.tagKeys)) {
    body['TagKeys'] = request.tagKeys;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'UntagResources',
    version = '2020-12-09',
    protocol = 'HTTPS',
    pathname = `/v2/openapi/untagresources`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Removes tags from resources.
 *
 * @description Removing tags from resources helps simplify resource management, optimize system performance, and mitigate potential security vulnerabilities. After a tag is removed from a resource, the system automatically deletes the tag if the tag is not added to other resources.
 *
 * @param request UntagResourcesRequest
 * @return UntagResourcesResponse
 */
async function untagResources(request: UntagResourcesRequest): UntagResourcesResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return untagResourcesWithOptions(request, headers, runtime);
}

model UpdateInstanceRequest {
  aliasName?: string(name='AliasName', description='The alias of the instance.', example='instance-test'),
  instanceDescription?: string(name='InstanceDescription', description='The description of the instance.', example='the test instance'),
  instanceName?: string(name='InstanceName', description='The name of the instance whose information you want to update.

This parameter is required.', example='instance-test'),
  network?: string(name='Network', description='(Deprecated) The network type of the instance. Valid values: NORMAL and VPC_CONSOLE. Default value: NORMAL.', example='VPC'),
  networkSourceACL?: [ string ](name='NetworkSourceACL', description='The new sources of the network from which access is allowed. By default, all sources of networks are allowed. Valid value:

TRUST_PROXY: the console'),
  networkTypeACL?: [ string ](name='NetworkTypeACL', description='The new types of the network from which access is allowed. By default, all types of networks are allowed. Valid values:

*   INTERNET: the Internet
*   VPC: VPCs
*   CLASSIC: the classic network'),
}

model UpdateInstanceResponseBody = {
  requestId?: string(name='RequestId', description='The request ID, which can be used to troubleshoot issues.', example='3104C83E-6E82-57FB-BB88-8C64CCFDEF89'),
}

model UpdateInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateInstanceResponseBody(name='body'),
}

/**
 * @summary Updates instance information.
 *
 * @param request UpdateInstanceRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateInstanceResponse
 */
async function updateInstanceWithOptions(request: UpdateInstanceRequest, headers: map[string]string, runtime: $RuntimeOptions): UpdateInstanceResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.aliasName)) {
    body['AliasName'] = request.aliasName;
  }
  if (!$isNull(request.instanceDescription)) {
    body['InstanceDescription'] = request.instanceDescription;
  }
  if (!$isNull(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }
  if (!$isNull(request.network)) {
    body['Network'] = request.network;
  }
  if (!$isNull(request.networkSourceACL)) {
    body['NetworkSourceACL'] = request.networkSourceACL;
  }
  if (!$isNull(request.networkTypeACL)) {
    body['NetworkTypeACL'] = request.networkTypeACL;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'UpdateInstance',
    version = '2020-12-09',
    protocol = 'HTTPS',
    pathname = `/v2/openapi/updateinstance`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Updates instance information.
 *
 * @param request UpdateInstanceRequest
 * @return UpdateInstanceResponse
 */
async function updateInstance(request: UpdateInstanceRequest): UpdateInstanceResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return updateInstanceWithOptions(request, headers, runtime);
}

model UpdateInstanceElasticVCUUpperLimitRequest {
  elasticVCUUpperLimit?: float(name='ElasticVCUUpperLimit', description='The upper limit for the VCUs of the instance.

>  Valid values of the upper limit for the VCUs of an instance: **Number of reserved VCUs+0.1 to 2000**. You can upgrade or downgrade configurations to modify the number of reserved VCUs by increments or decrements of 1. You can dynamically modify the upper limit for the VCUs of an instance by increments or decrements of 0.1

This parameter is required.', example='6'),
  instanceName?: string(name='InstanceName', description='The name of the instance.

This parameter is required.', example='workshop-bj-ots1'),
}

model UpdateInstanceElasticVCUUpperLimitResponseBody = {
  requestId?: string(name='requestId', description='The request ID, which can be used to troubleshoot issues.', example='B37BBA04-D827-55C8-B901-5264B904E8C6'),
}

model UpdateInstanceElasticVCUUpperLimitResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateInstanceElasticVCUUpperLimitResponseBody(name='body'),
}

/**
 * @summary Modifies the upper limit for the VCUs of an instance in VCU mode (formerly reserved mode).
 *
 * @description *   **Before you call this operation, you must understand the billing and pricing of Tablestore. For more information, see [Billing overview](https://help.aliyun.com/document_detail/27291.html).**
 * *   After you enable scalability for an instance, the default upper limit for the VCUs of the instance is the sum of the scalability and the reserved VCUs.
 * *   To use more computing resources when your business grows, you can modify the upper limit for the VCUs of your instance. The new upper limit for the VCUs of your instance immediately takes effect.
 *
 * @param request UpdateInstanceElasticVCUUpperLimitRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateInstanceElasticVCUUpperLimitResponse
 */
async function updateInstanceElasticVCUUpperLimitWithOptions(request: UpdateInstanceElasticVCUUpperLimitRequest, headers: map[string]string, runtime: $RuntimeOptions): UpdateInstanceElasticVCUUpperLimitResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.elasticVCUUpperLimit)) {
    body['ElasticVCUUpperLimit'] = request.elasticVCUUpperLimit;
  }
  if (!$isNull(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'UpdateInstanceElasticVCUUpperLimit',
    version = '2020-12-09',
    protocol = 'HTTPS',
    pathname = `/v2/openapi/updateinstanceelasticvcuupperlimit`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Modifies the upper limit for the VCUs of an instance in VCU mode (formerly reserved mode).
 *
 * @description *   **Before you call this operation, you must understand the billing and pricing of Tablestore. For more information, see [Billing overview](https://help.aliyun.com/document_detail/27291.html).**
 * *   After you enable scalability for an instance, the default upper limit for the VCUs of the instance is the sum of the scalability and the reserved VCUs.
 * *   To use more computing resources when your business grows, you can modify the upper limit for the VCUs of your instance. The new upper limit for the VCUs of your instance immediately takes effect.
 *
 * @param request UpdateInstanceElasticVCUUpperLimitRequest
 * @return UpdateInstanceElasticVCUUpperLimitResponse
 */
async function updateInstanceElasticVCUUpperLimit(request: UpdateInstanceElasticVCUUpperLimitRequest): UpdateInstanceElasticVCUUpperLimitResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return updateInstanceElasticVCUUpperLimitWithOptions(request, headers, runtime);
}

model UpdateInstancePolicyRequest {
  instanceName?: string(name='InstanceName', description='The name of the instance.

This parameter is required.', example='my-test-12345'),
  policy?: string(name='Policy', description='The instance policy in the JSON format.

This parameter is required.', example='{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ots:*"
            ],
            "Resource": [
                "acs:ots:*:13791xxxxxxxxxxx:instance/myinstance*"
            ],
            "Principal": [
                "*"
            ],
            "Effect": "Allow",
            "Condition": {
                "StringEquals": {
                    "ots:TLSVersion": [
                        "1.2"
                    ]
                },
                "IpAddress": {
                    "acs:SourceIp": [
                        "192.168.0.1",
                        "172.16.0.1"
                    ]
                }
            }
        }
    ]
}'),
  policyVersion?: long(name='PolicyVersion', description='The version of the instance policy.

This parameter is required.', example='2'),
}

model UpdateInstancePolicyResponseBody = {
  code?: string(name='Code', description='The HTTP status code.', example='200'),
  message?: string(name='Message', description='The response message.', example='success'),
  requestId?: string(name='requestId', description='The request ID, which can be used to troubleshoot issues.', example='31D8120C-AC52-5CA9-BE4A-E4C6316E19AD'),
}

model UpdateInstancePolicyResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateInstancePolicyResponseBody(name='body'),
}

/**
 * @summary Modifies a Resource Access Management (RAM) policy for an instance.
 *
 * @param request UpdateInstancePolicyRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateInstancePolicyResponse
 */
async function updateInstancePolicyWithOptions(request: UpdateInstancePolicyRequest, headers: map[string]string, runtime: $RuntimeOptions): UpdateInstancePolicyResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }
  if (!$isNull(request.policy)) {
    body['Policy'] = request.policy;
  }
  if (!$isNull(request.policyVersion)) {
    body['PolicyVersion'] = request.policyVersion;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'UpdateInstancePolicy',
    version = '2020-12-09',
    protocol = 'HTTPS',
    pathname = `/v2/openapi/updateinstancepolicy`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Modifies a Resource Access Management (RAM) policy for an instance.
 *
 * @param request UpdateInstancePolicyRequest
 * @return UpdateInstancePolicyResponse
 */
async function updateInstancePolicy(request: UpdateInstancePolicyRequest): UpdateInstancePolicyResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return updateInstancePolicyWithOptions(request, headers, runtime);
}

